<?php

/**
 * @author  snow
 */
try {
	$url = 'http://hq.sinajs.cn/list=%s';
	$codes = array('s_sz002016');
	$url = sprintf($url,implode(',',$codes));
	$rel = file_get_contents($url);
	$start = strpos($rel,'"');
	$end = strpos($rel,'"',$start + 1);
	$content = substr($rel,$start + 1,($end - $start));
	$pis = explode(',',$content);
	if(floatval($pis[3]) >= 5 || floatval($pis[1] >= 13)){
		$r = array();
		if(floatval($pis[3]) >= 5){
			$r[] = sprintf('price up with :%f',floatval($pis[3]));
		}
		if(floatval($pis[1]) >= 13){
			$r[] = sprintf('price up to :%f',floatval($pis[1]));
		}
		require 'p3mailer/p3base/P3Base.php';
		$envelope = new P3Base_Mailer_Envelope;
		$envelope->setSubject('new stoack price');
		
		$envelope->setFrom('84381554@qq.com', 'blog');
		$envelope->addTo('nobody1986@163.com', 'me');
		$r = implode(' and ',$r);
		$envelope->setHTMLMessage(sprintf('new stoack price:<br />%s',$r));
		$envelope->setTextMessage(sprintf('new stoack price:\n%s',$r));
	
		$mailer = new P3Base_Mailer_Handler_SMTP('smtp.qq.com');
		$mailer->auth('84381554','19860527ycmhn');
		$mailer->perform($envelope);
	
		//close connection
		$mailer = null;
		}
	} catch(Exception $e) {
		echo '<hr /><b>Error Occured</b><br />';
		echo nl2br($e->getMessage());
}
?>